using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ManagementClinic.Data.Models.Mapping
{
    public class KHAM_BENH_DON_THUOCMap : EntityTypeConfiguration<KHAM_BENH_DON_THUOC>
    {
        public KHAM_BENH_DON_THUOCMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.GHI_CHU)
                .HasMaxLength(100);

            this.Property(t => t.MODIFY_USER)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("KHAM_BENH_DON_THUOC");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.ID_KHAM_BENH).HasColumnName("ID_KHAM_BENH");
            this.Property(t => t.ID_THUOC).HasColumnName("ID_THUOC");
            this.Property(t => t.SO_LUONG).HasColumnName("SO_LUONG");
            this.Property(t => t.DON_GIA).HasColumnName("DON_GIA");
            this.Property(t => t.THANH_TIEN).HasColumnName("THANH_TIEN");
            this.Property(t => t.GHI_CHU).HasColumnName("GHI_CHU");
            this.Property(t => t.MODIFY_USER).HasColumnName("MODIFY_USER");
            this.Property(t => t.MODIFY_DATE).HasColumnName("MODIFY_DATE");

            // Relationships
            this.HasRequired(t => t.KHAM_BENH)
                .WithMany(t => t.KHAM_BENH_DON_THUOC)
                .HasForeignKey(d => d.ID_KHAM_BENH);
            this.HasRequired(t => t.THUOC)
                .WithMany(t => t.KHAM_BENH_DON_THUOC)
                .HasForeignKey(d => d.ID_THUOC);

        }
    }
}
